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

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

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

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

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

f.u = d
f.t = d
f.y = b
b.s = a
b.q = d
a.x = f
a.v = b
a.u = i
d.o = a
i.u = d
i.t = d
i.y = b
assert i.u.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.y: B = None
        self.t: D = None
        self.txt = txt

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

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

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

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

f.u = d
f.t = d
f.y = b
b.s = a
b.q = d
a.x = f
a.v = b
a.u = i
d.o = a
i.u = d
i.t = d
i.y = b
assert i.u.o.v.txt == "b"