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

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

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

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

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

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

f = A("f")
a = B("a")
m = C("m")
d = D("d")
k = E("k")
e = F("e")
j = C("j")
b = E("b")

f.r = a
f.q = e
f.t = d
f.s = j
a.s = d
m.u = a
m.r = a
m.w = f
m.t = f
d.p = f
k.s = f
e.p = f
j.u = a
j.r = a
j.w = f
j.t = f
b.s = f
assert m.r.s.p.r.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.q: F = None
        self.t: D = None
        self.s: C = None
        self.txt = txt

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

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

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

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

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

f = A("f")
a = B("a")
m = C("m")
d = D("d")
k = E("k")
e = F("e")
j = C("j")
b = E("b")

f.r = a
f.q = e
f.t = d
f.s = j
a.s = d
m.u = a
m.r = a
m.w = f
m.t = f
d.p = f
k.s = f
e.p = f
j.u = a
j.r = a
j.w = f
j.t = f
b.s = f
assert m.r.s.p.r.s.p.txt == "f"