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

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

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

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

j = A("j")
b = B("b")
a = C("a")
n = D("n")
h = D("h")

j.y = b
j.o = b
j.q = a
b.o = a
b.u = h
a.y = h
a.t = j
a.q = b
n.y = a
n.v = a
n.x = b
h.y = a
h.v = a
h.x = b
assert b.u.y.q.u.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.q: C = None
        self.o: B = None
        self.txt = txt

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

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

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

j = A("j")
b = B("b")
a = C("a")
n = D("n")
h = D("h")

j.y = b
j.o = b
j.q = a
b.o = a
b.u = h
a.y = h
a.t = j
a.q = b
n.y = a
n.v = a
n.x = b
h.y = a
h.v = a
h.x = b
assert b.u.y.q.u.y.txt == "a"