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

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

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

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

b = A("b")
a = B("a")
j = C("j")
d = D("d")
i = C("i")
l = B("l")
f = A("f")

b.o = i
b.t = f
a.y = d
j.z = i
j.v = i
j.r = b
d.u = b
d.o = b
i.z = j
i.v = j
i.r = b
l.y = d
f.o = j
f.t = b
assert l.y.u.o.r.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.t: A = None
        self.txt = txt

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

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

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

b = A("b")
a = B("a")
j = C("j")
d = D("d")
i = C("i")
l = B("l")
f = A("f")

b.o = i
b.t = f
a.y = d
j.z = i
j.v = i
j.r = b
d.u = b
d.o = b
i.z = j
i.v = j
i.r = b
l.y = d
f.o = j
f.t = b
assert l.y.u.o.r.t.o.txt == "j"