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

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

class C:
    def __init__(self, txt: str):
        self.p: F = None
        self.y: E = None
        self.t: B = None
        self.o: F = None
        self.txt = txt

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

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

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

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

j.y = k
j.r = f
j.s = f
j.q = h
h.q = j
m.p = k
m.o = k
m.y = a
m.t = h
f.s = a
f.p = c
f.r = c
f.x = j
a.t = m
a.r = j
k.s = f
c.p = k
c.o = k
c.y = a
c.t = h
assert h.q.r.p.y.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: F = None
        self.r: D = None
        self.s: D = None
        self.q: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: F = None
        self.y: E = None
        self.t: B = None
        self.o: F = None
        self.txt = txt

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

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

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

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

j.y = k
j.r = f
j.s = f
j.q = h
h.q = j
m.p = k
m.o = k
m.y = a
m.t = h
f.s = a
f.p = c
f.r = c
f.x = j
a.t = m
a.r = j
k.s = f
c.p = k
c.o = k
c.y = a
c.t = h
assert h.q.r.p.y.r.q.txt == "h"