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

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

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

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

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

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

g = A("g")
m = B("m")
c = C("c")
a = D("a")
n = E("n")
l = F("l")
b = A("b")

g.r = n
g.p = a
m.t = b
m.p = n
c.q = l
c.v = l
c.r = l
c.x = g
c.t = g
c.o = a
a.q = b
a.y = n
n.q = m
n.p = m
n.o = a
n.t = a
n.s = c
n.x = c
l.t = m
b.r = n
b.p = a
assert b.p.q.p.y.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: E = None
        self.p: D = None
        self.txt = txt

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

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

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

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

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

g = A("g")
m = B("m")
c = C("c")
a = D("a")
n = E("n")
l = F("l")
b = A("b")

g.r = n
g.p = a
m.t = b
m.p = n
c.q = l
c.v = l
c.r = l
c.x = g
c.t = g
c.o = a
a.q = b
a.y = n
n.q = m
n.p = m
n.o = a
n.t = a
n.s = c
n.x = c
l.t = m
b.r = n
b.p = a
assert b.p.q.p.y.t.q.txt == "b"