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

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

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

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

g = A("g")
e = B("e")
a = C("a")
f = D("f")
j = D("j")

g.o = f
g.r = j
e.o = j
a.x = e
a.v = e
a.p = j
a.r = g
f.u = j
j.u = f
assert g.o.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.r: D = None
        self.txt = txt

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

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

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

g = A("g")
e = B("e")
a = C("a")
f = D("f")
j = D("j")

g.o = f
g.r = j
e.o = j
a.x = e
a.v = e
a.p = j
a.r = g
f.u = j
j.u = f
assert g.o.u.u.u.u.txt == "f"