class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.o: A = None
        self.t: A = None
        self.q: B = None
        self.txt = txt

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

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

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

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

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

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

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

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

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

b.x = j
b.o = c
b.t = c
b.q = h
h.u = j
h.x = e
j.v = c
e.v = b
e.q = j
e.z = j
d.v = b
c.x = d
c.o = b
c.t = b
c.q = h
assert e.v.o.q.txt == "h"