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

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

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

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

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

h = A("h")
b = B("b")
c = C("c")
a = D("a")
f = E("f")
k = E("k")

h.r = c
b.q = c
c.p = f
c.r = a
a.s = b
f.x = c
f.r = c
f.o = a
f.t = k
f.w = b
k.x = c
k.r = c
k.o = a
k.t = f
k.w = b
assert f.x.r.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

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

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

h = A("h")
b = B("b")
c = C("c")
a = D("a")
f = E("f")
k = E("k")

h.r = c
b.q = c
c.p = f
c.r = a
a.s = b
f.x = c
f.r = c
f.o = a
f.t = k
f.w = b
k.x = c
k.r = c
k.o = a
k.t = f
k.w = b
assert f.x.r.s.q.txt == "c"