class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.u: D = None
        self.x: D = None
        self.y: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: B = None
        self.x: C = None
        self.y: B = None
        self.o: D = None
        self.z: D = None
        self.txt = txt

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

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.q: B = None
        self.x: C = None
        self.y: B = None
        self.o: D = None
        self.z: D = None
        self.txt = txt

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

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

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

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

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