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

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

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

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

g = A("g")
f = B("f")
h = C("h")
k = D("k")
a = D("a")
b = B("b")
c = C("c")

g.u = f
g.t = f
g.p = a
g.r = c
f.v = b
h.o = c
k.x = g
a.x = g
b.v = f
c.o = h
assert c.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.t: B = None
        self.p: D = None
        self.r: C = None
        self.txt = txt

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

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

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

g = A("g")
f = B("f")
h = C("h")
k = D("k")
a = D("a")
b = B("b")
c = C("c")

g.u = f
g.t = f
g.p = a
g.r = c
f.v = b
h.o = c
k.x = g
a.x = g
b.v = f
c.o = h
assert c.o.o.o.o.o.txt == "h"