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

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

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

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

j = A("j")
e = B("e")
b = C("b")
i = D("i")
f = C("f")
g = B("g")
c = A("c")

j.o = g
j.u = f
j.x = f
e.r = g
e.z = j
b.p = c
b.z = g
b.x = f
i.y = f
i.r = f
i.z = g
i.s = b
f.p = c
f.z = g
f.x = b
g.r = e
g.z = c
c.o = g
c.u = f
c.x = b
assert e.r.z.x.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.u: C = None
        self.x: C = None
        self.txt = txt

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

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

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

j = A("j")
e = B("e")
b = C("b")
i = D("i")
f = C("f")
g = B("g")
c = A("c")

j.o = g
j.u = f
j.x = f
e.r = g
e.z = j
b.p = c
b.z = g
b.x = f
i.y = f
i.r = f
i.z = g
i.s = b
f.p = c
f.z = g
f.x = b
g.r = e
g.z = c
c.o = g
c.u = f
c.x = b
assert e.r.z.x.p.u.txt == "f"