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

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

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

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

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

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

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

g.s = m
m.y = d
k.p = b
f.r = m
b.q = m
b.r = c
b.s = c
b.y = j
b.v = g
b.p = a
a.u = k
c.q = m
c.r = b
c.s = b
c.y = k
c.v = g
c.p = a
j.p = b
d.r = m
assert d.r.y.r.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

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

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

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

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

g.s = m
m.y = d
k.p = b
f.r = m
b.q = m
b.r = c
b.s = c
b.y = j
b.v = g
b.p = a
a.u = k
c.q = m
c.r = b
c.s = b
c.y = k
c.v = g
c.p = a
j.p = b
d.r = m
assert d.r.y.r.y.r.txt == "m"