class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.z: C = None
        self.x: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: D = None
        self.v: A = None
        self.u: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.u: A = None
        self.v: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

n = A("n")
d = B("d")
j = C("j")
e = D("e")
c = A("c")

n.u = d
n.z = j
n.x = j
d.y = e
d.v = n
d.u = c
j.u = c
j.v = d
e.o = d
c.u = d
c.z = j
c.x = j
assert e.o.u.u.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.z: C = None
        self.x: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: D = None
        self.v: A = None
        self.u: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.u: A = None
        self.v: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

n = A("n")
d = B("d")
j = C("j")
e = D("e")
c = A("c")

n.u = d
n.z = j
n.x = j
d.y = e
d.v = n
d.u = c
j.u = c
j.v = d
e.o = d
c.u = d
c.z = j
c.x = j
assert e.o.u.u.v.txt == "n"