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

class B:
    def __init__(self, txt: str):
        self.t: A = None
        self.q: D = None
        self.z: A = None
        self.txt = txt

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

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

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

g = A("g")
f = B("f")
e = C("e")
b = D("b")
j = E("j")
i = B("i")
n = B("n")

g.x = e
g.q = e
g.y = j
f.t = g
f.z = g
f.q = b
e.s = f
b.r = f
b.q = n
b.p = j
j.w = b
i.t = g
i.z = g
i.q = b
n.t = g
n.z = g
n.q = b
assert j.w.p.w.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.y: E = None
        self.q: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: A = None
        self.q: D = None
        self.z: A = None
        self.txt = txt

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

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

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

g = A("g")
f = B("f")
e = C("e")
b = D("b")
j = E("j")
i = B("i")
n = B("n")

g.x = e
g.q = e
g.y = j
f.t = g
f.z = g
f.q = b
e.s = f
b.r = f
b.q = n
b.p = j
j.w = b
i.t = g
i.z = g
i.q = b
n.t = g
n.z = g
n.q = b
assert j.w.p.w.r.q.txt == "b"