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

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

class C:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.z: E = None
        self.y: C = None
        self.w: B = None
        self.r: C = None
        self.p: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.w: B = None
        self.q: D = None
        self.p: D = None
        self.z: C = None
        self.y: D = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.v: D = None
        self.y: F = None
        self.txt = txt

m = A("m")
c = B("c")
g = C("g")
f = D("f")
i = E("i")
d = F("d")
k = C("k")
b = F("b")

m.u = b
c.p = m
c.q = m
c.v = m
c.u = d
g.u = f
f.z = i
f.y = k
f.p = k
f.w = c
f.r = g
i.w = c
i.q = f
i.p = f
i.y = f
i.z = g
d.v = f
d.y = b
k.u = f
b.v = f
b.y = d
assert f.r.u.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: F = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.z: E = None
        self.y: C = None
        self.w: B = None
        self.r: C = None
        self.p: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.w: B = None
        self.q: D = None
        self.p: D = None
        self.z: C = None
        self.y: D = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.v: D = None
        self.y: F = None
        self.txt = txt

m = A("m")
c = B("c")
g = C("g")
f = D("f")
i = E("i")
d = F("d")
k = C("k")
b = F("b")

m.u = b
c.p = m
c.q = m
c.v = m
c.u = d
g.u = f
f.z = i
f.y = k
f.p = k
f.w = c
f.r = g
i.w = c
i.q = f
i.p = f
i.y = f
i.z = g
d.v = f
d.y = b
k.u = f
b.v = f
b.y = d
assert f.r.u.r.u.txt == "f"