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

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

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

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

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

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

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

n.r = m
l.t = m
g.u = m
b.o = l
b.p = g
b.r = m
m.q = b
m.o = g
k.y = l
assert l.t.q.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: E = None
        self.txt = txt

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

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

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

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

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

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

n.r = m
l.t = m
g.u = m
b.o = l
b.p = g
b.r = m
m.q = b
m.o = g
k.y = l
assert l.t.q.p.u.txt == "m"