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

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

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

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

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

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

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

m.u = f
f.v = b
f.p = d
f.r = m
d.t = m
d.u = i
d.p = b
c.v = f
c.q = f
c.w = i
b.s = d
b.y = d
b.r = f
i.y = c
l.v = f
l.q = f
l.w = i
assert f.p.u.y.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

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

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

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

m.u = f
f.v = b
f.p = d
f.r = m
d.t = m
d.u = i
d.p = b
c.v = f
c.q = f
c.w = i
b.s = d
b.y = d
b.r = f
i.y = c
l.v = f
l.q = f
l.w = i
assert f.p.u.y.q.p.txt == "d"