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

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

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

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

k = A("k")
j = B("j")
e = C("e")
c = D("c")
f = A("f")
h = C("h")

k.v = j
k.z = j
k.q = f
j.v = f
e.v = c
e.x = j
c.o = e
f.v = j
f.z = j
f.q = k
h.v = c
h.x = j
assert e.x.v.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.z: B = None
        self.q: A = None
        self.txt = txt

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

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

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

k = A("k")
j = B("j")
e = C("e")
c = D("c")
f = A("f")
h = C("h")

k.v = j
k.z = j
k.q = f
j.v = f
e.v = c
e.x = j
c.o = e
f.v = j
f.z = j
f.q = k
h.v = c
h.x = j
assert e.x.v.z.v.txt == "f"