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

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

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

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

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

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

c = A("c")
h = B("h")
l = C("l")
n = D("n")
j = E("j")
i = F("i")
a = C("a")

c.t = h
c.r = h
c.x = n
h.t = j
h.y = j
l.q = h
l.w = a
l.y = c
n.t = j
j.q = n
i.r = h
a.q = h
a.w = l
a.y = c
assert i.r.t.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.r: B = None
        self.x: D = None
        self.txt = txt

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

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

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

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

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

c = A("c")
h = B("h")
l = C("l")
n = D("n")
j = E("j")
i = F("i")
a = C("a")

c.t = h
c.r = h
c.x = n
h.t = j
h.y = j
l.q = h
l.w = a
l.y = c
n.t = j
j.q = n
i.r = h
a.q = h
a.w = l
a.y = c
assert i.r.t.q.t.txt == "j"