class A:
    def __init__(self, txt: str):
        self.q: F = 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: C = None
        self.w: H = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.r: A = None
        self.u: H = None
        self.s: G = None
        self.p: D = None
        self.q: D = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.p: C = None
        self.x: H = None
        self.txt = txt

class H:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

f = A("f")
n = B("n")
m = C("m")
d = D("d")
g = E("g")
b = F("b")
a = G("a")
l = H("l")
c = F("c")
j = C("j")

f.q = c
n.t = g
m.u = j
m.w = l
d.p = a
g.r = f
g.u = l
g.s = a
g.p = d
g.q = d
b.u = c
b.s = f
b.x = f
a.p = j
a.x = l
l.z = j
c.u = b
c.s = f
c.x = f
j.u = m
j.w = l
assert f.q.x.q.x.q.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: F = 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: C = None
        self.w: H = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.r: A = None
        self.u: H = None
        self.s: G = None
        self.p: D = None
        self.q: D = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.p: C = None
        self.x: H = None
        self.txt = txt

class H:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

f = A("f")
n = B("n")
m = C("m")
d = D("d")
g = E("g")
b = F("b")
a = G("a")
l = H("l")
c = F("c")
j = C("j")

f.q = c
n.t = g
m.u = j
m.w = l
d.p = a
g.r = f
g.u = l
g.s = a
g.p = d
g.q = d
b.u = c
b.s = f
b.x = f
a.p = j
a.x = l
l.z = j
c.u = b
c.s = f
c.x = f
j.u = m
j.w = l
assert f.q.x.q.x.q.x.q.txt == "c"