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

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

class C:
    def __init__(self, txt: str):
        self.o: D = None
        self.t: B = None
        self.u: F = None
        self.x: F = None
        self.txt = txt

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

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

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

g = A("g")
d = B("d")
j = C("j")
m = D("m")
b = E("b")
l = F("l")

g.p = l
g.s = b
d.v = m
d.o = b
j.o = m
j.t = d
j.u = l
j.x = l
m.p = l
b.q = m
b.y = d
l.p = g
l.r = g
l.s = b
l.u = j
assert m.p.p.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: F = None
        self.s: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.o: D = None
        self.t: B = None
        self.u: F = None
        self.x: F = None
        self.txt = txt

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

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

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

g = A("g")
d = B("d")
j = C("j")
m = D("m")
b = E("b")
l = F("l")

g.p = l
g.s = b
d.v = m
d.o = b
j.o = m
j.t = d
j.u = l
j.x = l
m.p = l
b.q = m
b.y = d
l.p = g
l.r = g
l.s = b
l.u = j
assert m.p.p.s.q.txt == "m"