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

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

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

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

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

b = A("b")
c = B("c")
g = C("g")
n = D("n")
k = E("k")
h = E("h")
d = D("d")

b.r = c
c.r = b
c.s = b
c.p = d
g.x = b
n.q = c
n.x = g
n.t = g
n.r = b
n.w = d
k.t = h
k.p = b
k.y = d
h.t = k
h.p = b
h.y = n
d.q = c
d.x = g
d.t = g
d.r = b
d.w = n
assert c.p.t.x.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

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

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

b = A("b")
c = B("c")
g = C("g")
n = D("n")
k = E("k")
h = E("h")
d = D("d")

b.r = c
c.r = b
c.s = b
c.p = d
g.x = b
n.q = c
n.x = g
n.t = g
n.r = b
n.w = d
k.t = h
k.p = b
k.y = d
h.t = k
h.p = b
h.y = n
d.q = c
d.x = g
d.t = g
d.r = b
d.w = n
assert c.p.t.x.r.txt == "c"