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

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

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

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

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

d.v = e
d.r = e
d.t = f
f.u = c
f.o = c
c.p = d
b.r = c
b.s = f
b.x = e
e.u = c
e.o = c
assert f.u.p.v.u.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.t: B = None
        self.r: B = None
        self.txt = txt

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

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

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

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

d.v = e
d.r = e
d.t = f
f.u = c
f.o = c
c.p = d
b.r = c
b.s = f
b.x = e
e.u = c
e.o = c
assert f.u.p.v.u.txt == "c"