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

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

class C:
    def __init__(self, txt: str):
        self.w: D = None
        self.u: E = None
        self.txt = txt

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

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

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

j = A("j")
l = B("l")
h = C("h")
i = D("i")
k = E("k")
n = F("n")
f = A("f")
b = C("b")

j.p = l
j.v = l
l.t = j
l.r = n
h.w = i
h.u = k
i.u = l
k.x = h
k.p = i
k.t = n
n.p = i
n.q = i
f.p = l
f.v = l
b.w = i
b.u = k
assert j.p.r.q.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.v: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: D = None
        self.u: E = None
        self.txt = txt

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

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

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

j = A("j")
l = B("l")
h = C("h")
i = D("i")
k = E("k")
n = F("n")
f = A("f")
b = C("b")

j.p = l
j.v = l
l.t = j
l.r = n
h.w = i
h.u = k
i.u = l
k.x = h
k.p = i
k.t = n
n.p = i
n.q = i
f.p = l
f.v = l
b.w = i
b.u = k
assert j.p.r.q.u.r.txt == "n"