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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

f = A("f")
h = B("h")
m = C("m")
a = D("a")
k = E("k")
e = F("e")
l = B("l")
g = B("g")

f.p = l
f.q = e
h.r = f
h.q = m
h.z = m
h.v = g
m.s = f
m.x = f
a.o = m
a.q = f
a.t = e
k.r = m
e.q = f
l.r = f
l.q = m
l.z = m
l.v = g
g.r = f
g.q = m
g.z = m
g.v = h
assert a.t.q.p.r.p.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.q: F = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

f = A("f")
h = B("h")
m = C("m")
a = D("a")
k = E("k")
e = F("e")
l = B("l")
g = B("g")

f.p = l
f.q = e
h.r = f
h.q = m
h.z = m
h.v = g
m.s = f
m.x = f
a.o = m
a.q = f
a.t = e
k.r = m
e.q = f
l.r = f
l.q = m
l.z = m
l.v = g
g.r = f
g.q = m
g.z = m
g.v = h
assert a.t.q.p.r.p.q.s.txt == "f"