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

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

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

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.p: A = None
        self.y: A = None
        self.q: A = None
        self.o: A = None
        self.txt = txt

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

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

d = A("d")
h = B("h")
l = C("l")
g = D("g")
j = E("j")
m = F("m")
a = C("a")
c = F("c")

d.p = c
h.r = g
h.y = g
l.s = g
l.p = a
g.v = d
g.p = d
g.y = d
g.q = d
g.o = d
j.o = c
j.y = h
j.r = h
j.s = m
j.q = a
j.v = a
m.r = d
a.s = g
a.p = l
c.r = d
assert m.r.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: F = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.p: A = None
        self.y: A = None
        self.q: A = None
        self.o: A = None
        self.txt = txt

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

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

d = A("d")
h = B("h")
l = C("l")
g = D("g")
j = E("j")
m = F("m")
a = C("a")
c = F("c")

d.p = c
h.r = g
h.y = g
l.s = g
l.p = a
g.v = d
g.p = d
g.y = d
g.q = d
g.o = d
j.o = c
j.y = h
j.r = h
j.s = m
j.q = a
j.v = a
m.r = d
a.s = g
a.p = l
c.r = d
assert m.r.p.r.txt == "d"