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

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.o: E = None
        self.w: C = None
        self.q: C = None
        self.r: E = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.t: B = None
        self.v: C = None
        self.p: C = None
        self.q: A = None
        self.y: B = None
        self.txt = txt

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

m = A("m")
f = B("f")
g = C("g")
c = D("c")
d = E("d")
b = E("b")
k = A("k")

m.y = c
f.x = c
f.o = d
f.w = g
f.q = g
f.r = b
g.t = f
c.t = f
c.y = f
c.v = g
c.p = g
c.q = k
d.v = b
d.q = c
b.v = d
b.q = c
k.y = c
assert f.o.q.y.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.o: E = None
        self.w: C = None
        self.q: C = None
        self.r: E = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.t: B = None
        self.v: C = None
        self.p: C = None
        self.q: A = None
        self.y: B = None
        self.txt = txt

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

m = A("m")
f = B("f")
g = C("g")
c = D("c")
d = E("d")
b = E("b")
k = A("k")

m.y = c
f.x = c
f.o = d
f.w = g
f.q = g
f.r = b
g.t = f
c.t = f
c.y = f
c.v = g
c.p = g
c.q = k
d.v = b
d.q = c
b.v = d
b.q = c
k.y = c
assert f.o.q.y.x.txt == "c"