class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.u: E = 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: A = None
        self.z: D = None
        self.o: E = None
        self.w: A = None
        self.q: E = None
        self.txt = txt

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

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

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

k.r = d
k.u = c
g.o = d
b.x = k
b.w = k
b.z = d
b.o = c
b.q = c
d.p = k
c.r = k
c.s = d
i.o = d
j.o = d
assert g.o.p.u.s.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.u: E = 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: A = None
        self.z: D = None
        self.o: E = None
        self.w: A = None
        self.q: E = None
        self.txt = txt

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

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

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

k.r = d
k.u = c
g.o = d
b.x = k
b.w = k
b.z = d
b.o = c
b.q = c
d.p = k
c.r = k
c.s = d
i.o = d
j.o = d
assert g.o.p.u.s.p.u.txt == "c"