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

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

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

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

c = A("c")
i = B("i")
b = C("b")
g = D("g")
h = D("h")
k = A("k")
j = A("j")

c.o = g
c.x = g
i.p = h
b.u = i
g.z = k
g.x = b
g.p = h
h.z = k
h.x = b
h.p = g
k.o = g
k.x = g
j.o = h
j.x = g
assert b.u.p.p.z.x.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.x: D = None
        self.txt = txt

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

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

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

c = A("c")
i = B("i")
b = C("b")
g = D("g")
h = D("h")
k = A("k")
j = A("j")

c.o = g
c.x = g
i.p = h
b.u = i
g.z = k
g.x = b
g.p = h
h.z = k
h.x = b
h.p = g
k.o = g
k.x = g
j.o = h
j.x = g
assert b.u.p.p.z.x.x.u.txt == "i"